const express = require('express');
const router = express.Router();
const {getHeroes, getHeroesById, addHeroes, updateHeroes, deleteHeroes} = require('../service/HeroesService');

class HeroesController {
  static initRouter() {
    //查询全部数据
    router.get('/', getHeroes);

    //根据id查询数据
    router.get('/:id', getHeroesById);

    //根据id边距数据
    router.put('/:id', updateHeroes);

    //根据id删除数据
    router.delete('/:id', deleteHeroes);

    //添加数据
    router.post('/', addHeroes);

    return router;
  }
}

module.exports = HeroesController.initRouter();